@extends('public.home_base')
@section('title', '登录')

@section('content')
    <link rel="stylesheet" href="/static/css/index-style.css">
    <section class="center_container">
        <section class="login_container">
            <div class="banner">
                <p>
                    效率成就品牌
                    &emsp;
                    诚信铸就未来
                </p>
            </div>
            <div class="content">
                <form id="login_form" action="" method="post">
                    {{csrf_field()}}
                    <div class="box">
                        <div class="inner_title">
                            <span class="f20 text_orange">登录</span>
                            {{--                            <a href="login&type=sms" class="fr text_gray">短信登录</a>--}}
                        </div>
                        <ul>
                            <li>
                                <span class="cl">邮箱：</span>
                                <div>
                                    <input type="text" name="email" placeholder="请输入邮箱">
                                </div>
                            </li>
                            <li>
                                <span class="cl">密码：</span>
                                <div>
                                    <input type="password" name="password" placeholder="请输入密码">
                                </div>
                            </li>
                            <li>
                                <span class="cl">&nbsp;</span>
                                <div>
                                    <label>
                                    </label>
                                    <a href="zhaohuipw" class="fr text_gray">忘记密码</a>
                                </div>
                            </li>
                            <li>
                                <span class="cl">&nbsp;</span>
                                <div>
                                    <button type="submit" class="btn btn_primary btn_submit">登录</button>
                                    <p class="text_center mt10">还没有账户？<a href="reg">立即注册</a></p>
                                </div>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
        </section>
    </section>
@endsection
@section('script')
    <script src="/static/js/jquery.form.min.js"></script>
    <script type="text/javascript" src="/static/js/jquery.validation/1.14.0/jquery.validate.js"></script>
    <script type="text/javascript" src="/static/js/jquery.validation/1.14.0/validate-methods.js"></script>
    <script type="text/javascript" src="/static/js/jquery.validation/1.14.0/messages_zh.js"></script>
    <script>
        $(function () {
            $("#login_form").validate({
                rules: {
                    email: {
                        required: true,
                        minlength: 3,
                        maxlength: 20
                    },
                    password: {
                        required: true,
                    },
                },
                onkeyup: false,
                focusCleanup: true,
                success: "valid",
                submitHandler: function (form) {
                    $('.btn_submit').attr('disabled', 'disabled');
                    $(form).ajaxSubmit({
                        type: 'post',
                        url: "",
                        success: function (data) {
                            if (data.msg === 'success') {
                                layer.msg('成功!', {icon: 1, time: 1000}, function () {
                                    window.location = '/';
                                })
                            } else {
                                layer.msg(data.data.error, {icon: 2, time: 2000,});
                                setTimeout(function () {
                                    $('.btn_submit').removeAttr('disabled');
                                }, 2000);
                            }
                        },
                        error: function (XmlHttpRequest, textStatus, errorThrown) {
                            layer.msg('server error!', {icon: 2, time: 1000}, function () {
                                //parent.layer.close(index);
                                window.location.reload();
                            });
                        }
                    });
                }
            });
        });
    </script>
@endsection